import http from '@/utils/request'
// 商品分类商品类别数据
function getProductCategoriesReq() {
  return http({
    method: 'get',
    url: '/api/v1/product_categories',
  })
}
//获取商品列表 分页
function getProductListReq(page, per) {
  return http({
    method: 'get',
    url: '/api/v1/products',
    params: { page, per },
  })
}
//  名字搜索
function getProductNameSeachReq(name, page = 1, per = 10) {
  return http({
    method: 'get',
    url: '/api/v1/products',
    params: { page, per, name },
  })
}

// 分类搜索
function getProductCategorySeachReq(category, page = 1, per = 10) {
  return http({
    method: 'get',
    url: '/api/v1/products',
    params: { page, per, category },
  })
}
//商品详情
function getProductDetailReq(id) {
  return http({
    method: 'get',
    url: '/api/v1/products/' + id,
  })
}
//获取商品评论信息
function getProductCommentsReq(product_id) {
  return http({
    method: 'get',
    url: '/api/v1/product_comments/' + product_id,
  })
}
//发布评论 content内容 coverImage图片地址
function postProductCommentsReq(product_id, content, coverImage) {
  return http({
    method: 'post',
    url: '/api/v1/product_comments/' + product_id,
    data: { content, coverImage },
  })
}
//轮播图接口
function getBannersReq() {
  return http({
    method: 'get',
    url: '/api/v1/banners',
  })
}
export {
  getProductCategoriesReq,
  getProductListReq,
  getProductNameSeachReq,
  getProductCategorySeachReq,
  getProductDetailReq,
  getProductCommentsReq,
  postProductCommentsReq,
  getBannersReq,
}
